﻿<link href="~/Content/bootstrap-switch.min.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap-switch.min.js"></script>
<div class="container">
    <!--<ul class="nav nav-tabs-custom clearfix">
		<li class="active"><a>支付方式</a></li>
    </ul>-->
    <table class="table">
        <thead>
            <tr>
                <th>支付方式</th>
                <th></th>
                <th class="td-operate">操作</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                @{
                    string controller, action;
                    
                }
                @foreach (var paymentPlugin in Model)
                {
                <tr>
                    <td>@paymentPlugin.name</td>
                    <td width="100px">
                    <div class="switch switch-mini"><input class="bootstrapSwitch" pluginid="@paymentPlugin.pluginId" type="checkbox" data-size="mini" data-on-text="开启" data-off-text="关闭" @(paymentPlugin.enable ? "checked" : "") /></div>
                    </td>
                    <td class="td-operate"><span class="btn-a"><a href="edit?pluginId=@(paymentPlugin.pluginId)">编辑</a></span></td>
                </tr>
                }
         </tbody>
     </table>
</div>

<script>

    $(function () {
        $(function () {
            $(".bootstrapSwitch").bootstrapSwitch({
                onSwitchChange:function(event,state){
                    var pluginId=$(this).attr('pluginid');
                    var switcher = $(this);
                    var loading = showLoading();
                    $.post('./Enable', { pluginId: pluginId, enable: state }, function (result) {
                        loading.close();
                        if (result.success) {
                            switcher.bootstrapSwitch('state', state);
                        }
                        else{
                            switcher.bootstrapSwitch('state', !state); 
                            $.dialog.errorTips('操作失败!失败原因：'+result.msg);
                        }
                    }, "json");
                }
            });
        });
    });


</script>